<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 16px;">
      <el-breadcrumb-item :to="{ path: '/' }">
        <i class="el-icon-s-promotion"></i> 后台管理
      </el-breadcrumb-item>
      <el-breadcrumb-item>商品列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-divider></el-divider>

    <el-row gutter="20">
      <el-col span="6" v-for="p in productArr">
        <el-card>
          <a :href="'/detail.html?id='+p.id">
            <img :src="p.url" width="100%" height="233">
          </a>

          <p style="font-size: 14px;height: 30px">
            <a :href="'/detail.html?id='+p.id">
              {{p.title}}
            </a>
          </p>
          <p>
            <b>￥{{p.price}}</b> <s>{{p.oldPrice}}</s>
            <span style="float: right">销量:{{p.saleCount}}件</span>
          </p>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      productArr:[],
      }
    },
  methods:{
    handleSelect(key, keyPath) {
      location.href = "/result.html?id="+key;
    }
  },
  created:function () {
    //获取商品数据
    axios.get("/product/selectIndex").then(function (response) {
      exports.productArr = response.data;
    })
  },
  mounted() {
    this.loadProductList();
  }
}
</script>